package learn_concurrent._7;

import java.util.concurrent.locks.ReentrantLock;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class T4 {
	static final Logger logger = LoggerFactory.getLogger(T4.class);
	
	
	static final ReentrantLock LOCK = new ReentrantLock();
	public static void main(String[] args) {
		Thread t1 = new Thread(() -> {
			logger.info("想要获得锁");
			try {
				LOCK.lockInterruptibly();
			} catch (InterruptedException e) {
//				e.printStackTrace();
				logger.info("被打断了");
				return;
			}
			try {
				logger.info("获得锁");
			} finally {
				LOCK.unlock();
			}
		});
		
		LOCK.lock();
		t1.start();
		t1.interrupt();
		
	}

}
